/**
 *
 */
package it.unical.canonaco.rende.igpe.game.cbv.guilayer.sprites;
 
import java.awt.image.BufferedImage;
 
 
/**
 * @author Massimo Canonaco
 *
 */
@Deprecated
public class SpriteSheetCharacter
{
        /** */
        static private final int ROW_ON_POSITION = 0;
       
        /** */
        static private final int ROW_WALK = 1;
       
        /** */
        static private final int ROW_ATTACK = 2;
       
        /** */
        static private final int ROW_DAMAGED = 3;
       
        /** */
        static private final int ROW_DEATH = 4;
       
        /** */
        static private final int MAX_ANIMATION_ON_POSITION = 3;
       
        /** */
        static private final int MAX_ANIMATION_WALK = 10;
       
        /** */
        static private final int MAX_ANIMATION_ATTACK = 13;
       
        /** */
        static private final int MAX_ANIMATION_DAMAGED = 9;
       
        /** */
        static private final int MAX_ANIMATION_DEATH = 9;
       
        /** */
        static public final int ON_POSITION = 0;
       
        /** */
        static public final int WALK = 1;
       
        /** */
        static public final int ATTACK = 2;
       
        /** */
        static public final int DAMAGED = 3;
       
        /** */
        static public final int DEATH = 4;
       
        /** */
        private int step;
       
        /** */
        private int currentType;
       
        /** */
        private BufferedImage overallImage;
       
        public SpriteSheetCharacter()
        {
                step = 0;
        }
       
        public BufferedImage getImage()
        {
                BufferedImage result = null;
               
                if(step >= getMax(currentType))
                {
                        step = 0;
                        if(currentType == 5)
                        {
                                currentType = 0;
                        }
                        else
                        {
                                currentType++;
                        }
                }
               
                switch (currentType)
                {
                case ON_POSITION:
//                      System.out.println(step);
//                      overallImage.getSubimage(arg0, arg1, arg2, arg3)
                        result = overallImage.getSubimage(step*128,ROW_ON_POSITION*128, 128, 128);
                        break;
                case WALK:
                        result = overallImage.getSubimage(step*128,ROW_WALK*128, 128, 128);
                        break;
                case ATTACK:
                        result = overallImage.getSubimage(step*128,ROW_ATTACK*128, 128, 128);
                        break;
                case DAMAGED:
                        result = overallImage.getSubimage(step*128,ROW_DAMAGED*128, 128, 128);
                        break;
                case DEATH:
                        result = overallImage.getSubimage(step*128,ROW_DEATH*128, 128, 128);
                        break;
                default:
                        break;
                }
               
//              step++;
                return result;
        }
       
        public BufferedImage getImage(int type)
        {
                BufferedImage result = null;
               
                if(currentType != type)
                {
                        step = 0;
                        currentType = type;
                }
               
                switch (currentType)
                {
                case ON_POSITION:
//                      System.out.println(step);
//                      overallImage.getSubimage(arg0, arg1, arg2, arg3)
                        result = overallImage.getSubimage(step*128,ROW_ON_POSITION*128, 128, 128);
                        break;
                case WALK:
                        result = overallImage.getSubimage(step*128,ROW_WALK*128, 128, 128);
                        break;
                case ATTACK:
                        result = overallImage.getSubimage(step*128,ROW_ATTACK*128, 128, 128);
                        break;
                case DAMAGED:
                        result = overallImage.getSubimage(step*128,ROW_DAMAGED*128, 128, 128);
                        break;
                case DEATH:
                        result = overallImage.getSubimage(step*128,ROW_DEATH*128, 128, 128);
                        break;
                default:
                        break;
                }
               
                return result;
        }
 
        /** */
        public int getMax(int type)
        {
                int result = -1;
               
                switch (type) {
                case ON_POSITION:
                        result =  MAX_ANIMATION_ON_POSITION;
                        break;
                case WALK:
                        result = MAX_ANIMATION_WALK;
                        break;
                case ATTACK:
                        result = MAX_ANIMATION_ATTACK;
                        break;
                case DAMAGED:
                        result = MAX_ANIMATION_DAMAGED;
                        break;
                case DEATH:
                        result = MAX_ANIMATION_DEATH;
                        break;
                default:
                        break;
                }
               
                return result;
        }
        /**
         * @return the overallImage
         */
        public BufferedImage getOverallImage()
        {
                return overallImage;
        }
 
       
        /**
         * @param overallImage the overallImage to set
         */
        public void setOverallImage(BufferedImage overallImage) {
                this.overallImage = overallImage;
        }
       
        /** */
        public void updateSprite()
        {
                ++step;
//              switch (currentType) {
//              case ON_POSITION:
//                      step = step % MAX_ANIMATION_ON_POSITION;
//                      break;
//              case WALK:
//                      step = step % MAX_ANIMATION_WALK;
//                      break;
//              case ATTACK:
//                      step = step % MAX_ANIMATION_ATTACK;
//                      break;
//              case DAMAGED:
//                      step = step % MAX_ANIMATION_DAMAGED;
//                      break;
//              case DEATH:
//                      step = step % MAX_ANIMATION_DEATH;
//                      break;
//              default:
//                      break;
//              }
        }
}